package com.limao.Tool;


/**
 * 主干道派送员工具类
 * @author Niekq
 *
 */
public class MRUtil {

	public static int[][] worktime = new int[][]{
		{21600000,28800000},{28800000,36000000},{36000000,43200000},
		{43200000,50400000},{50400000,57600000},{57600000,64800000},
		{64800000,72000000},{72000000,79200000}
	};
	
	//根据片区id自由组合, 并对组合结果分页(起止片区均未定)
	public static int[][] procgroup(int[] areaids, int start, int limit){
		int[][] groupareaid = new int[limit][2];
		int index = 0;
		int mark  = 0;
		for(int i=0; i<areaids.length; i++){
			for(int j=0; j<areaids.length; j++){
				if(i != j){
					if(index >= start && index < (start + limit)){
						groupareaid[mark][0]=areaids[i];
						groupareaid[mark][1]=areaids[j];
						mark ++;
					}
					index++;
				}
			}
		}
		
		return groupareaid;
	}
	
	//根据片区id自由组合, 并对组合结果分页(起始片区已定)
	public static int[][] procgroup(int startareaid, int[] areaids, int start, int limit){
		int[][] groupareaid = new int[limit][2];
		int mark  = 0;
		for(int i=0; i<areaids.length; i++){
			if(i >= start && i < (start + limit)){
				groupareaid[mark][0]=startareaid;
				groupareaid[mark][1]=areaids[i];
				mark ++;
			}
		}
		
		return groupareaid;
	}
	
	public static int[] covertStringToInt(String[] ids){
		int[] int_ids = new int[ids.length];
		
		for(int i=0; i<ids.length; i++){
			int_ids[i] = CacheClass.getIntValue(ids[i]);
		}
		
		return int_ids;
	}
	
	public static boolean checkMRWorktime(int[] timeperiod, Long createtime){
		int time = (int)((createtime + 8 * 60 * 60 * 1000) % (24 * 3600 * 1000));
		for(int i : timeperiod){
			if(time >= worktime[i][0] && time <= worktime[i][1]){
				return true;
			}
		}
		return false;
	}
}
